﻿using Caffeine.Core.Test.TestModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace Caffeine.Core.Test
{
    [TestClass]
    public class ModelPropertyPrimitivesTester
    {
        [TestMethod]
        public void StringPropertyValidationTest()
        {
            IModelFactory factory = new ModelFactory();
            IValidationHelper validator = new ValidationHelper();

            ModelForPropertyValidationTesting viewModel = factory.CreateModel<ModelForPropertyValidationTesting>();
            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 10, 0);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, false, true, 10, 0);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Must be at least 10 character(s)");

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, false, true, 0, 0);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValue = "    ";
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, false, false, 0, 0);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Cannot have more than 0 character(s)");

            viewModel.StringValue = "animal";
            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 0, 10);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 8, 10);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Must be at least 8 character(s)");

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 1, 5);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Cannot have more than 5 character(s)");

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 1, 6);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 6, 6);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 7, 10);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Must be at least 7 character(s)");

            viewModel.StringValue = "  animal         ";
            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 6, 10);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValue = "  animal         ";
            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, false, 6, 10);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Cannot have more than 10 character(s)");

            viewModel.StringValueProperty.Commit();
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, false, false, 6, 10);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Cannot have more than 10 character(s)");

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod
            (
                false,
                false, 
                false, 
                0, 
                Int32.MaxValue,
                null,
                @"^[^<>\s\@]+(\@[^<>\s\@]+(\.[^<>\s\@]+)+)$", 
                "{0}",
                "{0}",
                "Invalid email address"
            );
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual
            (
                viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Invalid email address"
            );

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod
            (
                false, 
                false,
                false,
                0,
                Int32.MaxValue,
                null,
                null,
                "{0}",
                "{0}",
                String.Empty
            );
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod
            (
                false,
                false,
                false,
                0,
                Int32.MaxValue,
                null,
                String.Empty,
                "{0}",
                "{0}",
                null
            );
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);
            Assert.IsNull(viewModel.StringValueValidationErrors);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod
            (
                false,
                false,
                false,
                20,
                Int32.MaxValue,
                null,
                String.Empty,
                "Too few {0}",
                "Too many {0}",
                null
            );
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Too few 20");

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod
            (
                false,
                false,
                false,
                0,
                5,
                null,
                String.Empty,
                "Too few {0}",
                "Too many {0}",
                null
            );
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Too many 5");
        }

        [TestMethod]
        public void CharPropertyValidationTest()
        {
            IModelFactory factory = new ModelFactory();
            IValidationHelper validator = new ValidationHelper();

            ModelForPropertyValidationTesting viewModel = factory.CreateModel<ModelForPropertyValidationTesting>();
            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod<Char>(false, true, 'a', 'z');
            viewModel.CharValue = '`';
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, "Must be greater than or equal to a");

            viewModel.CharValue = '~';
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, "Must be less than or equal to z");

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod<Char>(false, true, 'a', 'z');
            viewModel.CharValueProperty.Commit();
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);
            Assert.IsNull(viewModel.CharValueValidationErrors);

            viewModel.CharValue = 'a';
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);
            Assert.IsNull(viewModel.CharValueValidationErrors);
            
            viewModel.CharValue = 'z';
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);
            Assert.IsNull(viewModel.CharValueValidationErrors);

            viewModel.CharValue = 'c';
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);
            Assert.IsNull(viewModel.CharValueValidationErrors);

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod<Char>(false, false, 'a', 'z', null, "Too small {0}", "Too big {0}");
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);
            Assert.IsNull(viewModel.CharValueValidationErrors);

            viewModel.CharValue = '`';
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, "Too small a");

            viewModel.CharValue = '~';
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, "Too big z");

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod<Char>(false, true, 'a', 'z', null, "Too small {0}", "Too big {0}");
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);
            Assert.IsNull(viewModel.CharValueValidationErrors);
        }

        [TestMethod]
        public void NullableCharPropertyValidationTest()
        {
            IModelFactory factory = new ModelFactory();
            IValidationHelper validator = new ValidationHelper();

            ModelForPropertyValidationTesting viewModel = factory.CreateModel<ModelForPropertyValidationTesting>();
            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(false, true, 'a', 'z');
            viewModel.NullableCharValue = '`';
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, "Must be greater than or equal to a");

            viewModel.NullableCharValue = '~';
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, "Must be less than or equal to z");

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(false, true, 'a', 'z');
            viewModel.NullableCharValueProperty.Commit();
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValue = 'a';
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValue = 'z';
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValue = 'c';
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(false, false, 'a', 'z', String.Empty, "Too small {0}", "Too big {0}");
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValue = '`';
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, "Too small a");

            viewModel.NullableCharValue = '~';
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, "Too big z");

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(false, true, 'a', 'z', String.Empty, "Too small {0}", "Too big {0}");
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(true, true, 'a', 'z');
            viewModel.NullableCharValue = null;
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(false, true, 'a', 'z');
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(true, true, 'a', 'z', String.Empty, String.Empty, null);
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(true, true, 'a', 'z', String.Empty, String.Empty, null);
            viewModel.NullableCharValue = 'b';
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod<Char>(false, true, 'a', 'z', String.Empty, String.Empty, null);
            viewModel.NullableCharValue = null;
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);
            Assert.IsNull(viewModel.NullableCharValueValidationErrors);
        }

        [TestMethod]
        public void StringPropertyNonDefaultValueTest()
        {
            IValidationHelper validator = new ValidationHelper();
            ModelFactory factory = new ModelFactory();

            ModelForPropertyValidationTesting viewModel = factory.CreateModel<ModelForPropertyValidationTesting>();
            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(true, true, true, 1, 2);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 1, 2);
            viewModel.StringValueProperty.Validate();
            Assert.IsFalse(viewModel.StringValueIsInvalid);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, false, true, 1, 2);
            viewModel.StringValueProperty.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(false, true, true, 1, 2);
            viewModel.StringValue = "b";
            viewModel.StringValueProperty.Commit();
            viewModel.StringValue = viewModel.StringValueProperty.GetDefaultValue();
            Assert.IsTrue(viewModel.StringValueIsInvalid);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(true, false, true, 1, 2);
            viewModel.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.StringValueProperty.ValidationMethod = validator.CreateStringValidationMethod(true, false, true, 1, 2, "Please give me a value!!", null, String.Empty, null, String.Empty);
            viewModel.Validate();
            Assert.IsTrue(viewModel.StringValueIsInvalid);
            Assert.AreEqual(viewModel.StringValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.StringValueValidationErrors.ElementAt(0).ErrorDescription, "Please give me a value!!");
        }

        [TestMethod]
        public void CharPropertyNonDefaultValueTest()
        {
            IValidationHelper validator = new ValidationHelper();
            ModelFactory factory = new ModelFactory();

            ModelForPropertyValidationTesting viewModel = factory.CreateModel<ModelForPropertyValidationTesting>();
            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod(true, true, 'b', 'd');
            viewModel.CharValueProperty.Validate();
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod(false, true, 'b', 'd');
            viewModel.CharValueProperty.Validate();
            Assert.IsFalse(viewModel.CharValueIsInvalid);

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod(false, false, 'b', 'd');
            viewModel.CharValueProperty.Validate();
            Assert.IsTrue(viewModel.CharValueIsInvalid);

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod(false, true, 'b', 'd');
            viewModel.CharValue = 'b';
            viewModel.CharValueProperty.Commit();
            viewModel.CharValue = viewModel.CharValueProperty.GetDefaultValue();
            Assert.IsTrue(viewModel.CharValueIsInvalid);

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod(true, false, 'b', 'd');
            viewModel.Validate();
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.CharValueProperty.ValidationMethod = validator.CreateValueTypeValidationMethod(true, false, 'b', 'd', "Why didn't you give me a value?", String.Empty, null);
            viewModel.Validate();
            Assert.IsTrue(viewModel.CharValueIsInvalid);
            Assert.AreEqual(viewModel.CharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.CharValueValidationErrors.ElementAt(0).ErrorDescription, "Why didn't you give me a value?");
        }

        [TestMethod]
        public void NullableCharPropertyNonDefaultValueTest()
        {
            IValidationHelper validator = new ValidationHelper();
            ModelFactory factory = new ModelFactory();

            ModelForPropertyValidationTesting viewModel = factory.CreateModel<ModelForPropertyValidationTesting>();
            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod(true, true, 'b', 'd');
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod(false, true, 'b', 'd');
            viewModel.NullableCharValueProperty.Validate();
            Assert.IsFalse(viewModel.NullableCharValueIsInvalid);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod(true, true, 'b', 'd');
            viewModel.NullableCharValue = 'b';
            viewModel.NullableCharValueProperty.Commit();
            viewModel.NullableCharValue = viewModel.NullableCharValueProperty.GetDefaultValue();
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod(true, false, 'b', 'd');
            viewModel.Validate();
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, ValidationHelper.ValueRequiredErrorMessage);

            viewModel.NullableCharValueProperty.ValidationMethod = validator.CreateNullableValueTypeValidationMethod(true, false, 'b', 'd', "You should have given me a value!", null, String.Empty);
            viewModel.Validate();
            Assert.IsTrue(viewModel.NullableCharValueIsInvalid);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.Count(), 1);
            Assert.AreEqual(viewModel.NullableCharValueValidationErrors.ElementAt(0).ErrorDescription, "You should have given me a value!");
        }

        [TestMethod]
        public void ValueRequiredMessageTest()
        {
        }
    }
}
